package com.z.test;

import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import javax.persistence.criteria.Root;
public class Bean {
    private String name;
    private String age;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = "1";
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }

    public static void main(String[] args) {
        try {
            PropertyDescriptor[] pds = Introspector.getBeanInfo(Bean.class).getPropertyDescriptors();
            for(PropertyDescriptor pd : pds){
                System.out.println(pd.getName());
                Method readMethod = pd.getReadMethod();
                Method writeMethod = pd.getWriteMethod();
                System.out.println(pd.getValue(pd.getName()));
                System.out.println(pd.getName());
            }
        } catch (IntrospectionException e) {
            e.printStackTrace();
        }
    }
}